﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DHQGHN.DAL.Models.Admin;
namespace DHQGHN.PM0.Models.Admin
{
    public class DisabilityStatusModel
    {
        public string DISABILITY_STATUS_ID { get; set; }

        [Remote("CheckExistDisabilityStatusCode", "DisabilityStatus", ErrorMessage = "DisabilityStatusCodeExist", HttpMethod = "POST", AdditionalFields = "DISABILITY_STATUS_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập mã tình trạng")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa 12 ký tự")]
        [RegularExpression(@"^[a-zA-Z0-9]+[a-zA-Z0-9_]*[a-zA-Z0-9]*$", ErrorMessage = "Mã không đúng định dạng")]
        [Display(Name = "Mã tình trạng")]
        public string CODE { get; set; }

        [Remote("CheckExistDisabilityStatusName", "DisabilityStatus", ErrorMessage = "DisabilityStatusNameExist", HttpMethod = "POST", AdditionalFields = "DISABILITY_STATUS_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập tên tình trạng")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa 255 ký tự")]
        [Display(Name = "Tên tình trạng")]
        public string NAME { get; set; }

        public string DESCRIPTIONS { get; set; }
        public int DELETED { get; set; }
        public int RecordCount { get; set; }

        #region field in database
        public const string FIELD_DISABILITY_STATUS_ID = "DISABILITY_STATUS_ID";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        public const string FIELD_RECORD_COUNT = "RecordCount";
        #endregion

        public DisabilityStatusModel() { }

        public DisabilityStatusModel(DAL.Models.Admin.DisabilityStatusModel model)
        {
            DISABILITY_STATUS_ID = model.DISABILITY_STATUS_ID;
            CODE = model.CODE;
            NAME = model.NAME;
            DESCRIPTIONS = model.DESCRIPTIONS;
            DELETED = model.DELETED;
            RecordCount = model.RecordCount;
        }
        internal DAL.Models.Admin.DisabilityStatusModel toDALModel()
        {
            DAL.Models.Admin.DisabilityStatusModel model = new DAL.Models.Admin.DisabilityStatusModel()
            {
                DISABILITY_STATUS_ID=DISABILITY_STATUS_ID,
                CODE=CODE,
                NAME=NAME,
                DESCRIPTIONS=DESCRIPTIONS,
                RecordCount=RecordCount

            };
            return model;
        }
    }
}